package com.game.thrones.controller.webpage;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.game.thrones.constant.Errors;
import com.game.thrones.controller.BaseController;
import com.game.thrones.controller.input.DataInput;
import com.game.thrones.controller.input.PageInput;
import com.game.thrones.controller.output.BaseOutput;
import com.game.thrones.controller.output.PageOutput;
import com.game.thrones.controller.output.ResultResponseBeanUtil;
import com.game.thrones.controller.output.SelectOutput;
import com.game.thrones.domain.KbmContent;
//import com.game.thrones.domain.department.DepartmentDO;
import com.game.thrones.domain.webpage.WebCourseDO;
import com.game.thrones.domain.webpage.WebEndemicDO;
import com.game.thrones.domain.webpage.WebJobDO;
import com.game.thrones.exception.GameGlobalException;
//import com.game.thrones.service.department.DepartmentService;
import com.game.thrones.service.web.WebEndemicService;
import com.game.thrones.util.OSSUploadUtil;
import com.game.thrones.util.StringUtils;
//import com.game.thrones.vo.EndemicVO;

//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;

//@Api(value = "网站-地方中心", description = "网站-地方中心-田春阳", produces = "application/json")
@Controller
public class WebEndemicController extends BaseController {
	private Logger log = LoggerFactory.getLogger(getClass());
	@Autowired
	WebEndemicService webEndemicService;
//	@Autowired
//	DepartmentService departmentService;
////	@ApiOperation(value = "已开通列表(网站用)", notes = "已开通列表(网站用)")
//	@ResponseBody
//	@RequestMapping(value = "/web/webEndemic/openedList", method = RequestMethod.POST)
//	public BaseOutput<List<WebEndemicDO>> openedList(HttpServletRequest request ) {
//		Map<String,Object> param = new HashMap<String,Object>();
//		param.put("opened",new Integer(1));
//		List<WebEndemicDO> entityList = webEndemicService.find(param) ;
//		List<WebEndemicDO> outList = new ArrayList<WebEndemicDO>();
//		for (WebEndemicDO entity : entityList) {
//			WebEndemicDO output = new WebEndemicDO();
//			DepartmentDO department=departmentService.findOneById(entity.getWebEndemicId());
//			if(department!=null){
//				BeanUtils.copyProperties(entity, output);
//				output.setEndemicName(department.getName());
//				if (StringUtils.isNotEmpty(output.getImg1())) {
//					output.setImg1Url(OSSUploadUtil.getUrl(output.getImg1()));
//				}
//				outList.add(output);
//			}
//		}
//		return ResultResponseBeanUtil.success(outList);
//	}
////	@ApiOperation(value = "列表(网站用)", notes = "列表(网站用)")
//	@ResponseBody
//	@RequestMapping(value = "/web/webEndemic/list", method = RequestMethod.POST)
//	public BaseOutput<List<WebEndemicDO>> list(HttpServletRequest request ) {
//		List<WebEndemicDO> entityList = webEndemicService.findAll( ) ;
//		List<WebEndemicDO> outList = new ArrayList<WebEndemicDO>();
//		for (WebEndemicDO entity : entityList) {
//			WebEndemicDO output = new WebEndemicDO();
//			DepartmentDO department=departmentService.findOneById(entity.getWebEndemicId());
//			if(department!=null){
//			BeanUtils.copyProperties(entity, output);
//			output.setEndemicName(department.getName());
//			if (StringUtils.isNotEmpty(output.getImg1())) {
//				output.setImg1Url(OSSUploadUtil.getUrl(output.getImg1()));
//			}
//			outList.add(output);
//			}
//		}
//		return ResultResponseBeanUtil.success(outList);
//	}
//
//	@ApiOperation(value = "分页列表(内部用)", notes = "分页列表(内部用)")
//	@ResponseBody
//	@RequestMapping(value = "/web/webEndemic/listByPage", method = RequestMethod.POST)
//	public PageOutput<WebEndemicDO> listByPage(HttpServletRequest request, @RequestBody PageInput input) {
//		KbmContent kbmContent = getCurrentInfo(request);
//		input.setKbmContent(kbmContent);
//		List<WebEndemicDO> entityList = webEndemicService.findByPage(input);
//		List<WebEndemicDO> outputList =new ArrayList<WebEndemicDO>();
//		for(WebEndemicDO entity:entityList){
//			WebEndemicDO output = entity;
//			DepartmentDO department=departmentService.findOneById(entity.getWebEndemicId());
//			if(department!=null){
//				output.setEndemicName(department.getName());
//			}
//			if (StringUtils.isNotEmpty(output.getImg1())) {
//				output.setImg1Url(OSSUploadUtil.getUrl(output.getImg1()));
//			}
//			outputList.add(output);
//		}
//		Integer total = webEndemicService.countByPage(input);
//		return ResultResponseBeanUtil.pageSuccess(outputList, input.getSize(), input.getPage(), total);
//	}
//
//	@ApiOperation(value = "新增", notes = "新增")
//	@ResponseBody
//	@RequestMapping(value = "/web/webEndemic/add", method = RequestMethod.POST)
//	public BaseOutput<Void> add(HttpServletRequest request, @Valid @RequestBody WebEndemicDO input) {
//		KbmContent kbmContent = getCurrentInfo(request);
//		if (kbmContent == null) {
//			throw new GameGlobalException(Errors.MODIFY_ERROR);
//		}
//		input.setKbmContent(kbmContent);
//		webEndemicService.add(input);
//		return ResultResponseBeanUtil.success();
//	}
//
//	@ApiOperation(value = "修改", notes = "修改")
//	@ResponseBody
//	@RequestMapping(value = "/web/webEndemic/update", method = RequestMethod.POST)
//	public BaseOutput<Void> update(HttpServletRequest request, @Valid @RequestBody WebEndemicDO input) {
//		KbmContent kbmContent = getCurrentInfo(request);
//		if (kbmContent == null) {
//			throw new GameGlobalException(Errors.MODIFY_ERROR);
//		}
//		input.setKbmContent(kbmContent);
//		webEndemicService.update(input);
//		return ResultResponseBeanUtil.success();
//	}
//	@ApiOperation(value = "删除", notes = "删除")
//	@ResponseBody
//	@RequestMapping(value = "/web/webEndemic/delete", method = RequestMethod.POST)
//	public BaseOutput<Void> delete(HttpServletRequest request, @Valid @RequestBody DataInput input) {
//		KbmContent kbmContent = getCurrentInfo(request);
//		WebEndemicDO entity = webEndemicService.findOneById( input.getDataId());
//		if (entity == null) {
//			throw new GameGlobalException(Errors.DATA_NOTEXIST);
//		}
//		webEndemicService.del(entity);
//		return ResultResponseBeanUtil.success();
//	}
//	@ApiOperation(value = "获取默认地方中心", notes = "获取默认地方中心")
//	@ResponseBody
//	@RequestMapping(value = "/web/webEndemic/getDefaultEndemic", method = RequestMethod.POST)
//	public BaseOutput<EndemicVO> getDefaultEndemic(HttpServletRequest request ) {
//		return ResultResponseBeanUtil.success(webEndemicService.findEndemicVOByRequest(request));
//	}
//	@ApiOperation(value = "根据ID获取", notes = "根据ID获取")
//	@ResponseBody
//	@RequestMapping(value = "/web/webEndemic/findOneById", method = RequestMethod.POST)
//	public BaseOutput<WebEndemicDO> findOneById(HttpServletRequest request, @Valid @RequestBody DataInput input) {
//		WebEndemicDO entity = webEndemicService.findOneById(  input.getDataId());
//		DepartmentDO department=departmentService.findOneById(entity.getWebEndemicId());
//		if(department!=null){
//			entity.setEndemicName(department.getName());
//		}
//		if (StringUtils.isNotEmpty(entity.getImg1())) {
//			entity.setImg1Url(OSSUploadUtil.getUrl(entity.getImg1()));
//		}
//		return ResultResponseBeanUtil.success(entity);
//	}
//	@ApiOperation(value = "下拉数据", notes = "下拉数据")
//	@ResponseBody
//	@RequestMapping(value = "/web/webEndemic/dropdown", method = RequestMethod.POST)
//	public BaseOutput<List<EndemicVO>> dropdown(HttpServletRequest request ) {
//		List<DepartmentDO> entityList = departmentService.findEndemic();
//		List<EndemicVO> outputList = new ArrayList<EndemicVO>();
//		for(DepartmentDO entity:entityList){
//			EndemicVO output = new EndemicVO();
//			output.setEndemicId(entity.getId());
//			output.setEndemicName(entity.getName());
//			outputList.add(output);
//		}
//		return ResultResponseBeanUtil.success(outputList);
//	}
}
